package com.mccken.designpattern.proxy.proxy3;

import java.lang.reflect.Proxy;

import com.mccken.designpattern.proxy.support.MetricsCollector;

/**
 * @program: mccken-collect
 * @description:
 * @author: mccken
 * @create: 2022-10-26 20:20
 **/
public class MetricsCollectorProxy {
	private MetricsCollector metricsCollector;
	
	public MetricsCollectorProxy() {
		this.metricsCollector = new MetricsCollector();
	}
	
	public Object createProxy(Object proxiedObject) {
		ClassLoader classLoader = proxiedObject.getClass().getClassLoader();
		Class<?>[] interfaces = proxiedObject.getClass().getInterfaces();
		DynamicProxyHandler dynamicProxyHandler = new DynamicProxyHandler(proxiedObject);
		return Proxy.newProxyInstance(classLoader,interfaces,dynamicProxyHandler);
	}
}
